import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: () => import('../views/login.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/register.vue')
  },
  {
    path: '/admin/:role/:userName',
    name: 'Manage',
    component: () => import(/* webpackChunkName: "about" */ '../views/Manage.vue'),
    children: [
      { path: '/admin/:role/:userName', name: 'admin', component: () => import('../views/admin.vue') },
      { path: '/admin/userManager/:role/:userName', name: 'UserManager', component: () => import('../views/UserManager.vue') }
    ]
  },
  {
    path: '/user/:userName',
    name: 'UserManage',
    component: () => import(/* webpackChunkName: "about" */ '../views/user_view/UserManage.vue'),
    children: [
      { path: '/user/:userName', name: 'UserPost', component: () => import('../views/user_view/recipe.vue') },
      { path: '/user/myself/:userName', name: 'MyInfo', component: () => import('../views/user_view/MyInfo.vue') },
     /* { path: '/user/submit/:userName', name: 'SchoolCanteen', component: () => import('../views/user_view/SchoolCanteen.vue') },*/
    ]
  },
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
